* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  background-color: #1e1e1e;
  color: #d4d4d4;
  overflow-x: hidden;
}

.editor-container {
  width: 100%;
  margin: 0 auto;
  background-color: #1e1e1e;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.editor-header {
  background-color: #2d2d30;
  padding: 12px 20px;
  border-bottom: 1px solid #3c3c40;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.editor-title {
  font-size: 16px;
  font-weight: 500;
  color: #cccccc;
}

.editor-toolbar {
  display: flex;
  gap: 10px;
}

.toolbar-btn {
  background-color: #3c3c40;
  color: #cccccc;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: background-color 0.2s;
}

.toolbar-btn:hover {
  background-color: #4d4d50;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #6a9955;
  font-size: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #6a9955;
}

/* --- 编辑器布局 --- */
.editor-wrapper {
  position: relative;
  height: 500px;
  overflow: hidden;
}

.line-numbers {
  position: absolute;
  left: 0;
  top: 0;
  width: 50px;
  height: 100%;
  background-color: #2d2d30;
  color: #858585;
  text-align: right;
  padding: 10px 5px;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  border-right: 1px solid #3c3c40;
  z-index: 2;
}

.editor-content {
  position: absolute;
  left: 50px;
  /* 行号区宽度 */
  top: 0;
  right: 0;
  height: 100%;
  padding: 10px;
}

#code-editor {
  width: 100%;
  height: 100%;
  background-color: transparent;
  color: #d4d4d4;
  border: none;
  resize: none;
  outline: none;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.5;
  tab-size: 4;
  position: relative;
  z-index: 1;
}

/* 语法高亮样式 */
.keyword {
  color: #569cd6;
}

.string {
  color: #ce9178;
}

.comment {
  color: #6a9955;
}

.function {
  color: #dcdcaa;
}

.number {
  color: #b5cea8;
}

.operator {
  color: #d4d4d4;
}

.bracket {
  color: #ffd700;
}

/* JavaScript 内置对象和方法样式 */
.builtin {
  color: #4ec9b0;
  font-weight: 500;
}

.method {
  color: #dcdcaa;
}

/* 新增高亮样式 */
.class {
  color: #4ec9b0;
  font-weight: 500;
}

.regex {
  color: #d7ba7d;
  background-color: rgba(215, 186, 125, 0.1);
  padding: 0 2px;
  border-radius: 2px;
}

.string.template {
  color: #ce9178;
  background-color: rgba(206, 145, 120, 0.1);
}

.boolean {
  color: #569cd6;
  font-weight: 500;
}

.null {
  color: #569cd6;
  font-style: italic;
}

/* JSON 特定样式 */
.key {
  color: #9cdcfe;
}

/* HTML 特定样式 */
.tag {
  color: #569cd6;
}

.attribute {
  color: #92c5f7;
}

/* CSS 特定样式 */
.selector {
  color: #d7ba7d;
}

.property {
  color: #9cdcfe;
}

.value {
  color: #ce9178;
}

/* 自动补全弹窗 */
.autocomplete-popup {
  position: absolute;
  background-color: #252526;
  border: 1px solid #3c3c40;
  border-radius: 6px;
  max-height: 300px;
  overflow: hidden;
  z-index: 1000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  display: none;
  min-width: 400px;
  backdrop-filter: blur(10px);
}

.autocomplete-header {
  padding: 8px 12px;
  background-color: #3c3c40;
  color: #cccccc;
  font-size: 12px;
  border-bottom: 1px solid #3c3c40;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.autocomplete-list {
  max-height: 210px;
  overflow-y: auto;
  position: relative;
}

.autocomplete-footer {
  padding: 6px 12px;
  background-color: #3c3c40;
  color: #cccccc;
  font-size: 11px;
  border-top: 1px solid #3c3c40;
  display: flex;
  justify-content: space-between;
}

.autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  border-left: 2px solid transparent;
  transition: all 0.15s ease;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
  background-color: #264f78;
  border-left-color: #007acc;
}

.autocomplete-item.selected {
  background-color: #04395e;
}

.autocomplete-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.icon-function {
  color: #c586c0;
}

.icon-variable {
  color: #4ec9b0;
}

.icon-keyword {
  color: #569cd6;
}

.icon-class {
  color: #4ec9b0;
}

.icon-method {
  color: #dcdcaa;
}

.icon-property {
  color: #9cdcfe;
}

.autocomplete-label {
  flex: 1;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

.autocomplete-detail {
  color: #858585;
  font-size: 11px;
  margin-left: 8px;
}

.autocomplete-doc {
  color: #999999;
  font-size: 11px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  max-width: 300px;
}

.autocomplete-item.selected .autocomplete-doc {
  color: #cccccc;
}

.usage-count {
  color: #6a9955;
  font-size: 10px;
  background-color: rgba(106, 153, 85, 0.2);
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 8px;
}

/* 滚动条样式 */
.autocomplete-list::-webkit-scrollbar {
  width: 12px;
}

.autocomplete-list::-webkit-scrollbar-track {
  background: #2d2d30;
  border-radius: 6px;
}

.autocomplete-list::-webkit-scrollbar-thumb {
  background: #3c3c40;
  border-radius: 6px;
  border: 3px solid #2d2d30;
}

.autocomplete-list::-webkit-scrollbar-thumb:hover {
  background: #4d4d50;
}

.autocomplete-list::-webkit-scrollbar-corner {
  background: #2d2d30;
}

/* 为 textarea 和 line-numbers 也添加滚动条样式 */
#code-editor::-webkit-scrollbar,
.line-numbers::-webkit-scrollbar {
  width: 12px;
}

#code-editor::-webkit-scrollbar-track,
.line-numbers::-webkit-scrollbar-track {
  background: #2d2d30;
  border-radius: 6px;
}

#code-editor::-webkit-scrollbar-thumb,
.line-numbers::-webkit-scrollbar-thumb {
  background: #3c3c40;
  border-radius: 6px;
  border: 3px solid #2d2d30;
}

#code-editor::-webkit-scrollbar-thumb:hover,
.line-numbers::-webkit-scrollbar-thumb:hover {
  background: #4d4d50;
}

#code-editor::-webkit-scrollbar-corner,
.line-numbers::-webkit-scrollbar-corner {
  background: #2d2d30;
}

.status-bar {
  background-color: #007acc;
  color: white;
  padding: 8px 20px;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 15px;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-connected {
  color: #6a9955;
}

.status-disconnected {
  color: #f48771;
}

/* 动画效果 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.autocomplete-popup {
  animation: fadeIn 0.15s ease-out;
}

/* 高亮匹配文本 */
.highlight-match {
  text-decoration: underline;
  font-weight: bold;
}

/* 文档信息容器 */
.autocomplete-doc-container {
  padding: 6px 12px 8px 40px;
  background-color: #2d2d30;
  border-top: 1px solid #3c3c40;
}

/* 键盘快捷键提示 */
.key-hint {
  background-color: #3c3c40;
  color: #cccccc;
  padding: 1px 4px;
  border-radius: 3px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 10px;
}

/* --- 语法高亮层样式 --- */
.highlight-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(100% - 20px);
  /* 减去 textarea 的 padding */
  height: calc(100% - 20px);
  /* 减去 textarea 的 padding */
  padding: 10px;
  /* 与 textarea 的 padding 相同 */
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  /* 保持空格和换行，并允许换行 */
  word-wrap: break-word;
  /* 长单词换行 */
  overflow: hidden;
  /* 隐藏溢出，由 textarea 控制 */
  pointer-events: none;
  /* 防止高亮层干扰鼠标事件 */
  z-index: 2;
}

/* 为高亮层中的 span 应用颜色 */
.highlight-layer .keyword {
  /* color: #569cd6; */
  color: #569cd6;
}

.highlight-layer .string {
  color: #ce9178;
}

.highlight-layer .comment {
  color: #6a9955;
}

.highlight-layer .function {
  color: #dcdcaa;
}

.highlight-layer .number {
  color: #b5cea8;
}

.highlight-layer .operator {
  color: #d4d4d4;
}

.highlight-layer .bracket {
  color: #ffd700;
}

/* JavaScript 内置对象和方法样式 */
.highlight-layer .builtin {
  color: #4ec9b0;
  font-weight: 500;
}

.highlight-layer .method {
  color: #dcdcaa;
}

/* 新增高亮层样式 */
.highlight-layer .class {
  color: #4ec9b0;
  font-weight: 500;
}

.highlight-layer .regex {
  color: #d7ba7d;
  background-color: rgba(215, 186, 125, 0.1);
  padding: 0 2px;
  border-radius: 2px;
}

.highlight-layer .string.template {
  color: #ce9178;
  background-color: rgba(206, 145, 120, 0.1);
}

.highlight-layer .boolean {
  color: #569cd6;
  font-weight: 500;
}

.highlight-layer .null {
  color: #569cd6;
  font-style: italic;
}

/* JSON 特定样式 */
.highlight-layer .key {
  color: #9cdcfe;
}

/* HTML 特定样式 */
.highlight-layer .tag {
  color: #569cd6;
}

.highlight-layer .attribute {
  color: #92c5f7;
}

/* CSS 特定样式 */
.highlight-layer .selector {
  color: #d7ba7d;
}

.highlight-layer .property {
  color: #9cdcfe;
}

.highlight-layer .value {
  color: #ce9178;
}

/* 确保 textarea 背景透明且在上层 */
#code-editor {
  background-color: transparent !important;
  /* 确保透明 */
  color: #d4d4d4;
  z-index: 1;
}

/* 搜索替换对话框样式 */
.search-replace-dialog {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Segoe UI Emoji', 'Segoe UI Symbol', sans-serif;
}

.search-replace-dialog input[type="text"] {
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-replace-dialog input[type="text"]:focus {
  border-color: #007acc;
  box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.2);
}

.search-replace-dialog button {
  transition: all 0.2s;
  font-family: inherit;
}

.search-replace-dialog button:hover {
  background-color: #e1e1e1 !important;
  transform: translateY(-1px);
}

.search-replace-dialog button:active {
  transform: translateY(0);
}

.search-replace-dialog .replace-all-btn:hover {
  background-color: #005a9e !important;
}

.search-replace-dialog label {
  font-size: 13px;
  color: #333;
  user-select: none;
}

.search-replace-dialog input[type="checkbox"] {
  accent-color: #007acc;
}

.search-replace-dialog .close-btn:hover {
  background-color: #f0f0f0;
  border-radius: 3px;
}

/* 搜索结果高亮 */
.search-highlight {
  background-color: #ffff00;
  color: #000;
  padding: 1px 2px;
  border-radius: 2px;
}

.search-highlight.current {
  background-color: #ff6b35;
  color: #fff;
  animation: pulse 1s ease-in-out;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .search-replace-dialog {
    width: 90vw !important;
    right: 5vw !important;
    top: 20px !important;
  }
}

/* 滚动条美化 */
.search-replace-dialog ::-webkit-scrollbar {
  width: 6px;
}

.search-replace-dialog ::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.search-replace-dialog ::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.search-replace-dialog ::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}